package cn.jaye.fabric.controller.rest;

import cn.jaye.fabric.application.GuessApplicationService;
import cn.jaye.fabric.application.command.GuessCommand;
import cn.jaye.fabric.application.command.GuessMatchCommand;
import cn.jaye.fabric.application.command.TestCommand;
import cn.jaye.fabric.common.util.ResultUtil;
import cn.jaye.fabric.domain.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author Jaye
 * @create 2018-06-05 16:42
 */

@RestController
@RequestMapping("guess")
public class GuessController {

    @Autowired
    private GuessApplicationService guessApplicationService;

    @PostMapping("/list")
    public String listEnd(HttpServletRequest request) {
        return ResultUtil.success(guessApplicationService.listGuessMatch());
    }

    @PostMapping("/list/score")
    public String listScore(HttpServletRequest request) {
        return ResultUtil.success(guessApplicationService.listsScore());
    }

    @PostMapping("/add")
    public String listEnd(HttpServletRequest request, GuessCommand guessCommand) {
//        guessApplicationService.guess(new User(), guessCommand);
        return ResultUtil.success();
    }

    @PostMapping("/create")
    public String create(HttpServletRequest request, GuessMatchCommand guessMatchCommand) {
        return ResultUtil.success(guessApplicationService.create(guessMatchCommand));
    }

    @PostMapping("/list/myguess")
    public String listMyguess(HttpServletRequest request) {
        return ResultUtil.success(guessApplicationService.listMyGuess());
    }

    @PostMapping("/list/allow")
    public String listAllow(HttpServletRequest request) {
        return ResultUtil.success(guessApplicationService.listGuessAllowMatch());
    }

    @PostMapping("/myself")
    public String myselfInfo(HttpServletRequest request) {
        return ResultUtil.success(guessApplicationService.infoMyRankAndPoint());
    }
    @PostMapping("/myguess/list")
    public String myguessList(HttpServletRequest request) {
        return ResultUtil.success(guessApplicationService.listMyAllGuess());
    }
}
